home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / bathints.zip / BH_03.DOC < prev    next >
Text File  |  1987-10-26  |  2KB  |  57 lines

  1.  
  2.                                   BAT-HINT # 3
  3.  
  4. **************************************************************************
  5.  
  6. from the BATHINTS library... part of the BATPOWER CONFERENCE from:
  7.  
  8.                          THE PAINFRAME OPUS/FIDO 261/1004
  9.  
  10.                         Baltimore, Maryland 1-301-488-7461
  11.  
  12. **************************************************************************
  13.  
  14.                                 The FOR command:
  15.                          Placing executable files in SET
  16.  
  17. The FOR command has the following syntax:
  18.  
  19.      FOR %%V IN (SET) DO command
  20.  
  21. While SET usually involves filenames with or without the global charcters
  22. (? and *), SET may include any executable file (i.e. .exe .com .bat) or any
  23. of the DOS internal commands. Note the example shown below:
  24.  
  25.     SAMPLE.BAT
  26.  
  27.     echo off
  28.     FOR %%V IN (*.doc) DO copy %%V c:\document
  29.  
  30. The batch file above will copy each *.doc file in the current drive and
  31. directory to c:\document. This batch file can be improved however, by
  32. a little creative rearrangement:
  33.  
  34.    BETTER.BAT
  35.  
  36.   echo off
  37.   FOR %%V IN (copy) DO %%V *.doc c:\document
  38.  
  39. What is the difference between sample.bat and better.bat? Sample.bat copies
  40. each *.doc file to c:\document one at a time, whereas better.bat copies the
  41. *.doc files to c:\document as if entered at the command line as:
  42.  
  43.     copy *.doc c:\document
  44.  
  45. Try it and see. Several public domain programs are available that copy and
  46. then erase files from source and destination directories (i.e. move.com),
  47. effectively moving the files from one subdirectory to another. The same
  48. function can be performed by the following command line placed in a batch
  49. file:
  50.  
  51.     FOR %%V IN (copy del) DO %%V *.* c:\otherdir
  52.  
  53. This batch file command line will copy all files in the current drive and
  54. directory to c:\otherdir then delete the files from the current drive and
  55. directory... essentially a "move" command.
  56.  
  57. ******************************************************** David Creasey